/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package converter;

import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.convert.Converter;
import model.dao.UserDAO;
import model.entity.User;
import model.service.UsersDAOService;

/**
 *
 * @author duy
 */
public class UserConverter implements Converter{
    
    private final UsersDAOService userServer = UserDAO.getInstance();

    @Override
    public Object getAsObject(FacesContext fc, UIComponent uic, String value) {
        return userServer.getusersbyID(Integer.valueOf(value));
        
    }

    @Override
    public String getAsString(FacesContext fc, UIComponent uic, Object value) {
        return ((User)value).getMauser()+"";
    }
    
}
